package com.example.demo.controller;

import com.example.demo.entity.dto.ResultBean;
import com.example.demo.service.PlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author lzc
 * @date 2021/11/10 16 36
 * discription
 */
@RestController
@RequestMapping("/platform")
public class PlatformController {

    @Autowired
    private PlatformService platformService;

    /**
     * 查询分页数据
     */
    @RequestMapping(method = RequestMethod.GET, value = "/normal")
    public ResultBean<?> listByPage(@RequestParam(name = "page", defaultValue = "1") int page,
                                    @RequestParam(name = "pageSize", defaultValue = "10") int pageSize,
                                    @RequestParam(name = "level",defaultValue = "省部级") String level) {
        return new ResultBean<>(platformService.listPlatformsByPage(page,pageSize,level));
    }

    /**
     * 查询单个
     */
    @RequestMapping(method = RequestMethod.GET, value = "/normal/{id}")
    public ResultBean<?> getById(@PathVariable("id") Integer id) {
        return new ResultBean<>(platformService.getById(id));
    }
}
